﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BLL
{
    using System.Data;

    public class BenhnhanBLL : DAL.BenhnhanDAL
    {   
        private string AddID(string id)
        {
            string s = id.Trim(); // bn01

            int len = s.Length; 
            string con = s.Substring(2); // 01
            string kq = s.Substring(0,2); // bn
            int so = Convert.ToInt32(con) + 1;
            if (so <= 9)
                kq += '0';
            kq += so;

            return kq;
        }

        public string CreateID()
        {
            string result = Select_max().Trim();
            if (result.Length > 2)
            {
                result = result.Substring(2);
            }
            else result = "";

            Int32 i =0;
            i = Convert.ToInt32(result);
            i++;

            
            return "BN" +i.ToString("#");
           
        }
        public Boolean check_SDT(string id)
        {
            if (id == "")
                return true;
            else if (id.Length < 10 || id.Length > 15)
                return false;
            else
            {
                string a = id.Substring(0, 2);
                if (a != "09" && a != "01" && a != "07")
                    return false;
                else
                    return true;
            }
        }
    }
}
